package calvin.study.springboot.factorybean;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

import calvin.study.springboot.model.configprop.Pet;

@Component
public class MyFactoryBean<T> implements FactoryBean<T> {
	private String msg;

	public MyFactoryBean() {
		this.msg = "通过构造方法实例化";
	}

	@Override
	public T getObject() throws Exception {
		MyFactoryBean myBean = new MyFactoryBean();
		myBean.msg="通过FactoryBean.getObject()创建实例";
		return (T) myBean;
	}

	@Override
	public Class<?> getObjectType() {
		return Pet.class;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
}
